home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1990 May & June & July / rerun-1990-05-06-07.d64 / assembly lang.ut (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  5KB  |  137 lines

  1. 10 rem :: assembly language utility
  2. 20 rem :: by eric jevon bryant
  3. 30 poke53280,0:poke53281,0:printchr$(5);:gosub1250:mn=1:a=1
  4. 40 rem :: main menu
  5. 50 op=-1:x=1:gosub1110:onmn-1goto60,320,540,810
  6. 60 rem :: conversions
  7. 70 cc=0:qi=-5*(x=2)+-4*(x=3)+-3*(x=4)+-8*(x=5):onx-1goto80,140,200,270
  8. 80 rem : decimal to hex
  9. 90 print"decimal number: ";:gosub860:ifqtthenop=-1:a=2:lm=1:mn=2:goto50
  10. 100 de=val(cc$(0)):ifde<0orde>65535thenprint"invalid number":print:goto90
  11. 110 gosub120:print"hex conversion: $";h$:print:goto80
  12. 120 h$="":forx=3to0step-1:x%=de/(16^x):de=de-x%*16^x:h$=h$+mid$(he$,x%+1,1)
  13. 130 next:return
  14. 140 rem : hex to decimal
  15. 150 print"hex number--------: ";:gosub860:ifqtthenop=-1:a=2:lm=1:mn=2:goto50
  16. 160 gosub170:print"decimal conversion:";de:print:goto140
  17. 170 d=0:q=3:forx=1to4:fory=0to15:ifmid$(cc$(0),x,1)=mid$(he$,y+1,1)then190
  18. 180 nexty
  19. 190 z=y*(16^(q)):d=d+z:q=q-1:nextx:de=int(d):return
  20. 200 rem : decimal to binary
  21. 210 print"decimal number---: ";:gosub860:ifqtthenop=-1:a=2:lm=1:mn=2:goto50
  22. 220 de=val(cc$(0)):ifde<0orde>255thenprint"invalid number":print:goto210
  23. 230 gosub240:print"binary conversion: ";b$:print:goto210
  24. 240 b$="":y=128:forx=1to8:ifde>=ythende=de-y:b$=b$+"1":goto260
  25. 250 ifde<ythenb$=b$+"0"
  26. 260 y=y-y/2:nextx:return
  27. 270 rem : binary to decimal
  28. 280 print"binary number:----: ";:gosub860:ifqtthenop=-1:a=2:lm=1:mn=2:goto50
  29. 290 gosub300:print"decimal conversion:";de:print:goto270
  30. 300 y=128:de=0:forx=1to8:ifmid$(cc$(0),x,1)="1"thende=de+y
  31. 310 y=y-y/2:nextx:return
  32. 320 rem :: change memory
  33. 330 qi=5:de=0:onx-1goto340,400
  34. 340 rem : change location
  35. 350 x$="starting address":mx=65535:n=0:ln=-1:gosub1030:ad=x:ln=0
  36. 360 ifqtthenop=-1:a=2:lm=1:mn=3:goto50
  37. 370 qi=3:x$="poke"+str$(ad):mx=255:n=-1:gosub1030:ifqtthen390
  38. 380 pokead,x:ad=ad+1:goto370
  39. 390 print:print"ending address:";ad:poke198,0:wait198,1:a=3:goto360
  40. 400 rem : insert message
  41. 410 print"input message:":qi=255:cc=1:gosub860:a=cc:println$;:cx=0:cy=5
  42. 420 x$="starting address":mx=65535:n=0:ln=0:cc=0:gosub1030:ad=x
  43. 430 print"output as (a)scii or (s)creen code: ";:cc=0:gosub880
  44. 440 ifqtthenmn=3:lm=1:a=2:op=-1:goto50
  45. 450 x$=left$(cc$(0),1):pt=-1*(x$="a")+-2*(x$="s"):ifpt=0thengoto430
  46. 460 println$:print"please wait....":forx=1to500:next:op=0:mn=3:x=3:gosub1110
  47. 470 forx=1toa:fory=1tolen(in$(x)):ifpt=1thennp=asc(mid$(in$(x),y,1)):goto480
  48. 480 b=y:printchr$(19);:sc=peek(646):poke646,peek(53281):printmid$(in$(x),y,1)
  49. 490 ifcy=22thency=5:cx=notcxand17:ifcx=0thena=x:op=0:mn=3:x=3:gosub1110:x=a:y=b
  50. 500 poke781,cy:poke782,cx:poke783,0:poke646,sc:cy=cy+1:sys65520
  51. 510 ifpt=2thennp=peek(1024)
  52. 520 print"poke";ad;",";np:pokead,np:ad=ad+1:nexty,x:print
  53. 530 print"ending address:";ad-1:poke198,0:wait198,1:qt=-1:goto440
  54. 540 rem :: examine memory
  55. 550 lm=1:qi=5:onx-1goto560,720
  56. 560 rem : examine locations
  57. 570 x$="starting address":mx=65535:ln=-1:gosub1030:ad=x
  58. 580 ifqtthenop=-1:mn=4:a=2:lm=1:goto50
  59. 590 forx=1to500:next:mn=6:op=-1:a=2:lm=4:x=1:gosub1110:md=x-1
  60. 600 ifmd=4thenprintchr$(peek(ad));:goto620
  61. 610 printad;":";:gosub650:ad=ad+1:printtab(15);ad;":";:gosub650:print:gosub700
  62. 620 geta$:ifa$=""thenad=ad+1:goto600
  63. 630 ifa$=chr$(133)thenqt=-1:goto580
  64. 640 poke198,0:wait198,1:poke198,0:goto600
  65. 650 de=peek(ad):ifmd=1thenprintde;:return
  66. 660 y=1:onmdgosub660,120,240
  67. 670 ifmd=2thenprinth$;
  68. 680 ifmd=3thenprintb$;
  69. 690 return
  70. 700 ifpeek(214)=23thenmn=6:a=2:op=0:x=z+1:gosub1110
  71. 710 return
  72. 720 rem : test bits
  73. 730 x$="object address":mx=65535:ln=-1:gosub1030:ad=x:print"value:";peek(ad);
  74. 740 ifqtthenmn=4:a=2:x=1:goto50
  75. 750 ad$=str$(ad):ad$=right$(ad$,len(ad$)-1)
  76. 760 print:de=peek(ad):forx=0to7:bt$(x)=mid$(str$(x),2,1):nextx:printad$;":";
  77. 770 printtab(8);:gosub240:forx=1to8:ifmid$(b$,9-x,1)="1"thenprintchr$(18);
  78. 780 printbt$(x-1);spc(3);chr$(146);:next:de=ad:gosub120:print"$";h$;":";spc(1);
  79. 790 forx=1to8:of$="off":ifmid$(b$,9-x,1)="1"thenof$=" on"
  80. 800 printof$;spc(1);:next:print:println$;:goto720
  81. 810 rem :: exit utility
  82. 820 rem : break into monitor
  83. 830 ifx=2thenpoke53280,11:poke53281,11:poke2,0:sys2
  84. 840 rem : quit utility
  85. 850 end
  86. 860 rem :: parser
  87. 870 forx=0tocc:in$(x)="":next
  88. 880 in$(0)="":qt=0:zl=0:zt=ti:zc=2:zd$=chr$(20):wd=40:cr$=chr$(13)
  89. 890 getz$:ifz$<>""then920
  90. 900 print"[164]"+chr$(157);
  91. 910 goto890
  92. 920 z=asc(z$):zl=len(in$(cc)):ifz=20thenprint" "+chr$(157);:goto950
  93. 930 ifzl=qithenifcc=1000thenreturn
  94. 940 ifz=13thenprintchr$(32);chr$(20);:ifcc=0thencc$(0)=in$(0):print:return
  95. 950 ifz=133thenprintchr$(28);"escape";cr$;chr$(5);:qt=-1:return
  96. 960 ifz=20andzl=0then890
  97. 970 ifz=20thenin$(cc)=left$(in$(cc),zl-1):printchr$(20);:goto890
  98. 980 ifz=134thenprint:ad=-1:gotoreturn
  99. 990 ifzl=qithenifcc=0then890
  100. 1000 ifzl=qithencc=cc+1
  101. 1010 in$(cc)=in$(cc)+z$:printz$;
  102. 1020 goto890
  103. 1030 rem :: input starting address
  104. 1040 printx$;": ";:gosub880:x=val(cc$(0)):ifqtthenreturn
  105. 1050 ifleft$(cc$(0),1)="$"thencc$(0)=right$(cc$(0),len(cc$(0))-1):z=1
  106. 1060 if(z=1)andnthencc$(0)="00"+cc$(0)
  107. 1070 ifz=1thengosub170:x=de
  108. 1080 if(x<0orx>mx)or(z=1andx=0)thenprint"invalid address":print:goto1040
  109. 1090 iflnthenprintln$;
  110. 1100 n=0:return
  111. 1110 rem :: menu plotting
  112. 1120 printchr$(147);tab(8);"assembly language utility":println$;:poke198,0
  113. 1130 y=2:printspc(19-(len(mn$(mn,x))/2));mn$(mn,x):println$:ifnotopthenreturn
  114. 1140 x$=str$(x):x$=right$(x$,1):printx$;">";chr$(32);mn$(mn,1+x):print
  115. 1150 x=x+1:y=y+1:ifx=5then1180
  116. 1160 ifmn$(mn,y)="*"then1180
  117. 1170 goto1140
  118. 1180 geta$:ifa$=""then1180
  119. 1190 ifa$=chr$(133)andmn<>1thena=a+1*(mn<>6):mn=lm:x=1:lm=1:goto1240
  120. 1200 z=val(a$):if(z=0)or(z=>x)then1180
  121. 1210 a=a+1:printchr$(19);:forx=1toz*2+1:print:next:printtab(3);chr$(18);
  122. 1220 printmn$(mn,z+1);chr$(146):forx=1to500:next:lm=mn:b=mn:mn=z+1:x=1
  123. 1230 ifmn<>1anda=3thenop=0:mn=b:x=z+1
  124. 1240 gosub1110:return
  125. 1250 rem :: initiation
  126. 1260 dimmn$(6,5)
  127. 1270 forx=1to6:fory=1to5:readmn$(x,y):nexty,x:he$="0123456789abcdef"
  128. 1280 forx=1to40:ln$=ln$+chr$(192):next:return
  129. 1290 data main menu,conversions,change memory,examine memory,exit utility
  130. 1300 data conversions,decimal to hex,hex to decimal,decimal to binary
  131. 1310 data binary to decimal
  132. 1320 data change memory,change locations,insert message,*,*
  133. 1330 data examine memory,examine location,examine bits,*,*
  134. 1340 data exit utility,break into monitor,quit utility,*,*
  135. 1350 data choose method of output,decimal values,hex values,binary values
  136. 1360 data asc ii code
  137.